package framework.util.queryFilter.vo;

import framework.util.layui._LayuiUtil;

/**
 * @author 吴宇亮 on 2019/2/12 0012 22:05
 */
public class PageBean {

    /** 默认第一页开始 **/
    public static final int DEFAULT_START_PAGE = 1;
    /** 默认一页为15条 **/
    public static final int DEFAULT_PAGE_ROWS = 15;

    /** 第几页，一页多少条，查询总条数 **/
    private int page;
    private int size;
    private Integer totals;
    /** limit的偏移量，每一页的条数（根据page和size算出来） **/
    private int offerset;
    private int rows;
    /** 是否获取总条数，默认获取 **/
    private boolean isGetTotals = true;

    public PageBean(int page, int size){
        this.page = page;
        this.size = size;

        //偏移量,条数, 参考博客：https://www.yiibai.com/mysql/limit.html
        //1, 1 => (0, 1); 1, 2 => (0, 2); 1, 15 => (0, 15); 2, 15 => (15, 15); 3, 15 => (30, 15)
        offerset = (page - 1) * size;
        rows = size;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public Integer getTotals() {
        return totals;
    }

    public void setTotals(Integer totals) {
        this.totals = totals;
    }

    public int getOfferset() {
        return offerset;
    }

    public void setOfferset(int offerset) {
        this.offerset = offerset;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public boolean getIsGetTotals() {
        return this.isGetTotals;
    }

    public void setIsGetTotals(boolean isGetTotals) {
        this.isGetTotals = isGetTotals;
    }
}
